// const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');
const path = require('path');
const {
    override,
    fixBabelImports,
    addLessLoader,
    addWebpackAlias,
    addWebpackPlugin,
    adjustWorkbox,
    addBabelPlugins,
    overrideDevServer
    // eslint-disable-next-line import/no-extraneous-dependencies
} = require('customize-cra');
/* config-overrides.js */
/* config-overrides.js */
module.exports = {
    webpack: override(
        addBabelPlugins(['@babel/plugin-proposal-optional-chaining']),
        addBabelPlugins(['@babel/plugin-proposal-nullish-coalescing-operator']),
        addWebpackAlias({
            '@': path.resolve(__dirname, 'src'),
            components: path.resolve(__dirname, 'src/components'),
            assets: path.resolve(__dirname, 'src/assets')
        }),
        adjustWorkbox(wb =>
            Object.assign(wb, {
                skipWaiting: true,
                exclude: (wb.exclude || []).concat('index.html')
            })
        ),

        fixBabelImports('import', {
            libraryName: 'antd',
            libraryDirectory: 'es',
            style: true
        }),
        addLessLoader({
            localIdentName: '[local]--[hash:base64:8]',
            javascriptEnabled: true,
            modifyVars: {}
        }),
        // addWebpackPlugin(new AntdDayjsWebpackPlugin())
    ),
    devServer: overrideDevServer(
        process.env.MOCK === 'SERVER' ? addMockServer() : null
    )
};
